<template>
    <div class="wrapper">
        <h2>对话框组件</h2>
        <div class="shape">
            <h3>效果展示</h3>
            <div>
                <Button @click="toggle" >点击查看样式</Button> 
                <Dialog v-model:visible="visible" :ok="f1" :cancel="f2">
                    <template v-slot:title>
                        <div><strong> 提示 </strong></div>          
                    </template>
                    <template v-slot:content>
                        <div>提示的内容</div>          
                    </template>
                </Dialog> 
            </div>
        </div>
        <div class="markdown-body">
            <pre><code>{{`
<!-- 请传递两个具名插槽 title 和 content  -->

<Dialog v-model:visible="visible" :ok="f1" :cancel="f2">
    <template v-slot:title>
        <div><strong> 提示 </strong></div>          
    </template>
    <template v-slot:content>
        <div>提示的内容</div>          
    </template>
</Dialog> 
            `}}</code></pre>
        </div>
    
    <div class="shape">
        <h3 @click="getCode">查看源码</h3>
        <main class="markdown-body" v-show="code">
<pre><code>{{
`<template>
    <Dialog v-model:visible="visible" :ok="f1" :cancel="f2">
        <template v-slot:title>
            <div><strong> 提示 </strong></div>          
        </template>
        <template v-slot:content>
            <div>提示的内容</div>          
        </template>
        </Dialog>
</template>

<script lang="ts">
import {ref} from 'vue'
import Dialog from '../lib/Dialog.vue'
export default {
    components: { Dialog},
    setup(){
        const visible = ref(false)
        const code=ref(false)
        const getCode=()=>{
                code.value=!code.value
            }
        const title='提示'
        const toggle=()=>{
            visible.value=!visible.value
        }
        const f1 =()=>{
            console.log('1')
        }
        const f2 =()=>{
            console.log('2')
        }
        return {visible,toggle,f1,f2,title,code,getCode}
    }
}
</script>`
}}</code></pre>
            </main>
        </div>
    </div>
</template>

<script lang="ts">
import {ref} from 'vue'
import Dialog from '../lib/Dialog.vue'
import Button from '../lib/Button.vue'
export default {
    components: { Dialog,Button },
    setup(){
        const visible = ref(false)
        const code=ref(false)
        const getCode=()=>{
                code.value=!code.value
            }
        const title='提示'
        const toggle=()=>{
            visible.value=!visible.value
        }
        const f1 =()=>{
            console.log('1')
        }
        const f2 =()=>{
            console.log('2')
        }
        return {visible,toggle,f1,f2,title,code,getCode}
    }
}
</script>

<style lang="scss" scoped>
.wrapper{
    max-width:800px;
    h2{
        padding-bottom: 30px;
        border-bottom: 1px solid rgb(212, 208, 208);
    }
    .shape{
        margin:30px 0px;
        >h3{
            margin-bottom: 10px;
        }
        >div{
            display: flex;
            padding: 50px;
            align-items: center;
            justify-content: center;
            border:1px solid rgb(212, 208, 208);
        }
    }
}
@media (max-width:500px) {
    .wrapper{
        max-width: 390px;
    }
              
}
</style>